package com.example.administrator.yuejian35.Club.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.administrator.yuejian35.Club.bean.Coach;
import com.example.administrator.yuejian35.Club.fragment.viewholder.CoachItemViewHolder;
import com.example.administrator.yuejian35.R;
import com.squareup.picasso.Picasso;

import java.util.ArrayList;
import java.util.List;

import static com.example.administrator.yuejian35.Config.CoachImages_URL;
import static com.example.administrator.yuejian35.Config.REM_URL;

/**
 * Created by HP on 2017/9/26.
 */

public class CoachListAdapter extends RecyclerView.Adapter {
    private Context context;
    private List<Coach> courseList=new ArrayList<>();


    public CoachListAdapter(Context c, List<Coach> courseList){
        this.context = c;
        this.courseList.addAll(courseList);


    }


    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        //1)  将item.xml 生成 itemView  -  View
        //2)  生成MyViewHolderd对象
        View itemView = LayoutInflater.from(context).inflate(R.layout.item_coach,parent,false);
        CoachItemViewHolder holder = new CoachItemViewHolder(itemView);
        return holder;
    }



    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
        //用于绑定数据
        //转换类型
        CoachItemViewHolder courseItemViewHolder= (CoachItemViewHolder) holder;


        courseItemViewHolder.coach_name.setText(courseList.get(position).getCoachname());
     /*   courseItemViewHolder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(context,CourseinfoActivity.class);
                intent.putExtra("courseid",courseList.get(position).getCourseid());
                context.startActivity(intent);
            }
        });*/
        Picasso.with(context)
                .load(CoachImages_URL+courseList.get(position).getCoachpic())
                .into(courseItemViewHolder.coach_pic);


    }



    @Override
    public int getItemCount() {
        return courseList.size();
    }
}

